import React, { Component } from 'react';
import '../styles/Register.scss'
import * as service from '../api/index'

class Register extends Component {
    constructor(props){
        super(props)
        this.state={
            phone:'',
            pass:''
        }
    }
    handleChange(e){
        this.setState({[e.target.name]:e.target.value})
    }
    async handleClick(){
        console.log(this.state);
        let res=await service.user_register({phone:this.state.phone,pass:this.state.pass})
        console.log(res.data);
    }
    render() {
        return (
            <div className='register'>
                <div className="input">
                    <input type="text" name='phone' value={this.state.phone} onChange={(e)=>{this.handleChange(e)}} placeholder='请输入用户名' />
                    <input type="password" name='pass' value={this.state.pass} onChange={(e)=>{this.handleChange(e)}} placeholder='请输入密码' />
                </div>
                <button onClick={()=>{this.handleClick()}}>注册</button>
                <a href="#">登录</a>
            </div>
        );
    }
}

export default Register;